package bean.life.annotation;

import bean.life.User;
import bean.life.AutoWiredBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.stereotype.Component;

/**
 * @date 2020/5/24 21:49
 */
@Configuration
/**
 * 测试{@link Import}注解
 */
@Import({MyParam.class})

/**
 * 默认是当前包下的路径。扫描到{@link Component}注解的bean，如{@link MyListener}
 */
@ComponentScan
public class AnnotationConfig {
	public AnnotationConfig() {
		System.out.println("AnnotationConfig ---------> 被实例化了");
	}

	/**
	 * 测试{@link Bean}注解注入到Spring
	 *
	 * @return
	 */
	@Bean
			(name = "userInConfig",initMethod = "my_init", destroyMethod = "my_destroy")
	public User getUser() {
		return new User();
	}

//	@Bean
//	public MyBeanPostProcessor getMyBeanPostProcessor() {
//		return new MyBeanPostProcessor();
//	}

	@Bean
	public AutoWiredBean autoWiredBean(){
		return new AutoWiredBean();
	}
}
